﻿using Ellanet.Classes;
using Ellanet.ViewModels;
using System;
using System.Collections.Generic;
using System.Windows;

namespace Ellanet.Windows
{
    public partial class PractiseWindow
    {
        public PractiseWindowViewModel Vm;

        public PractiseWindow(List<Sum> sums, TimeSpan interval)
        {
            InitializeComponent();
            Vm = new PractiseWindowViewModel(sums, interval);
            Vm.RequestViewClose += Vm_RequestViewClose;
            DataContext = Vm;
        }

        private void Vm_RequestViewClose()
        {
            Dispatcher.Invoke(delegate { DialogResult = true; });
            Dispatcher.Invoke(Close);
        }

        private void CloseButton_OnClick(object sender, RoutedEventArgs e)
        {
            DialogResult = false;
            Close();
        }
    }
}
